//
//  BKUserAskOrderCellTableViewCell.m
//  bestkeep
//
//  Created by windCould on 16/12/20.
//  Copyright © 2016年 utouu. All rights reserved.
//

#import "BKUserAskOrderCellTableViewCell.h"
#import "BKMyCommon.h"

@interface BKUserAskOrderCellTableViewCell ()

@property(nonatomic, strong)UIImageView *goodsImg;
@property(nonatomic, strong)UILabel *orderId;
@property(nonatomic, strong)UILabel *orderNumber;
@property(nonatomic, strong)UILabel *orderMoney;
@property(nonatomic, strong)UILabel *orderDesc;
@property(nonatomic, strong)UIView * lineView;

@end


@implementation BKUserAskOrderCellTableViewCell

+(BKUserAskOrderCellTableViewCell *)cellWithTableview:(UITableView *)tableview
{
    BKUserAskOrderCellTableViewCell * cell =[tableview dequeueReusableCellWithIdentifier:BKUserAskOrderCellTableViewCellId];
    if (!cell) {
        
        cell = [[BKUserAskOrderCellTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:BKUserAskOrderCellTableViewCellId];
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell;
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
   
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self) {
        
        [self setUpViews];
        
    }
    return self;
}

-(void)setUpViews
{
    self.backgroundColor = RGBCOLOR(242, 242, 242, 1);
    
    _goodsImg = [UIImageView new];
    _goodsImg.layer.borderWidth = 1;
    _goodsImg.layer.borderColor = RGBCOLOR(228, 228, 228,1).CGColor;
    [self.contentView addSubview:_goodsImg];
       
    _orderMoney = [UILabel new];
    _orderMoney.textColor = RGBCOLOR(68, 68, 68,1);
    _orderMoney.font = [UIFont systemFontOfSize:15];
    _orderMoney.textAlignment = NSTextAlignmentRight;
    [self.contentView addSubview:_orderMoney];
    
    _orderNumber = [UILabel new];
    _orderNumber.textColor = RGBCOLOR(136, 136, 136,1);
    _orderNumber.font = [UIFont systemFontOfSize:11];
    _orderNumber.textAlignment = NSTextAlignmentRight;
    [self.contentView addSubview:_orderNumber];
       
    _orderDesc = [UILabel new];//商品描述
    _orderDesc.textColor = RGBCOLOR(68, 68, 68,1);
    _orderDesc.font = [UIFont systemFontOfSize:13];
    _orderDesc.numberOfLines = 2;
    [self.contentView addSubview:_orderDesc];
    
    _lineView = [[UIView alloc]init];
    _lineView.backgroundColor = [UIColor whiteColor];
    [self.contentView addSubview:_lineView];
    
    
    [self layoutViews];
    
}

-(void)layoutViews
{
    [_goodsImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.contentView.mas_left).with.offset(10);
        make.top.mas_equalTo(self.contentView.mas_top).with.offset(7);
        make.width.mas_equalTo(@(61));
        make.height.mas_equalTo(@61);
    }];
    
    [_orderMoney mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(self.contentView.mas_top).with.offset(7);
        make.right.mas_equalTo(self.contentView.mas_right).with.offset(-10);
        make.width.mas_equalTo(@100);
        make.height.mas_equalTo(@(20));
    }];
    
    [_orderNumber mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(_orderMoney.mas_bottom).with.offset(3);
        make.right.mas_equalTo(self.contentView.mas_right).with.offset(-10);
        make.height.mas_equalTo(@(10));
    }];
    
    [_orderDesc mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.contentView.mas_top).with.offset(7);
        make.left.mas_equalTo(_goodsImg.mas_right).with.offset(10);
        make.right.mas_equalTo(_orderMoney.mas_left).with.offset(-28);
    }];
    
    [_lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.mas_equalTo(self.contentView.mas_bottom).offset(0);
        make.left.mas_equalTo(self.contentView.mas_left).offset(0);
        make.right.mas_equalTo(self.contentView.mas_right).offset(0);
        make.height.mas_equalTo(@(2));
    }];
    
}


-(void)setSingalOrderModel:(BKUserChatSignalOrderModel *)singalOrderModel
{
     _singalOrderModel = singalOrderModel;
     [_goodsImg  load:_singalOrderModel.goods_img placeholderImage: [UIImage imageNamed:@"pic_newGoods"]];
     _orderNumber.text = [NSString stringWithFormat:@"×%@",_singalOrderModel.amount];
     _orderMoney.text = [NSString stringWithFormat:@"¥ %.2f",[_singalOrderModel.member_price floatValue]];
     _orderDesc.text = [NSString stringWithFormat:@"%@",_singalOrderModel.goods_name];

}



@end
